<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript" src="../dist/jquery/jquery-1.8.3.js"></script>
<LINK rel=stylesheet type=text/css href="../css/style.css">
<html>
<head>
    <title>发布信息</title>
</head>
<BODY>
<DIV id=header class=wrap>
    <DIV id=logo><IMG src="../images/logo.gif"></DIV></DIV>
<DIV id=regLogin class=wrap>
    <DIV class=dialog>
        <DL class=clearfix>
            <DT>新房屋信息发布</DT>
            <DD class=past>填写房屋信息</DD></DL>
        <DIV class=box>
            <FORM id=add_action method=post name=add.action
                  action=house!add.action>
                <DIV class=infos>
                    <TABLE class=field>
                        <TBODY>
                        <TR>
                            <TD class=field>标　　题：</TD>
                            <TD><INPUT id=add_action_title class=text type=text name=htitle> </TD></TR>
                        <TR>
                            <TD class=field>价　　格：</TD>
                            <TD><INPUT id=add_action_price class=text type=text name=hprice> </TD></TR>
                        <TR>
                            <TD class=field>面　　积：</TD>
                            <TD><INPUT id=add_action_floorage class=text type=text name=hfloorage></TD></TR>
                        <TR>
                            <TD class=field>房产证日期：</TD>
                            <TD><INPUT class=text type=text name=hpubdate></TD></TR>
                        <TR>
                            <TD class=field>联系方式：</TD>
                            <TD><INPUT id=add_action_contact class=text type=text name=hcontact> </TD></TR>
                        <TR>
                            <TD class=field>详细信息：</TD>
                            <TD><TEXTAREA name=hdesc></TEXTAREA></TD></TR>


                        <TR>
                            <TD class=field>户　　型：</TD>
                            <TD>
                                <SELECT class=text name=type.tid>
                                    <%-- <OPTION selected value=1000>一室一厅</OPTION>--%>
                                </SELECT>
                            </TD></TR>

                        <TR>
                            <TD class=field>位　　置：</TD>
                            <TD>区：<SELECT class=text name=district.did>
                                <%--<OPTION selected value=1004>海淀区</OPTION>--%>
                            </SELECT>
                                街：<SELECT class=text name=street.sid>
                                <%--<OPTION selected value=1001>中关村大街</OPTION>--%>
                                </SELECT> </TD></TR></TBODY></TABLE>

                    <DIV class=buttons><INPUT value=立即发布 type=submit>

                    </DIV></DIV></FORM></DIV></DIV></DIV>
<DIV id=footer class=wrap>
    <DL>
        <DT>云和租房 © 2010 云和 京ICP证1000001号</DT>
        <DD>关于我们 · 联系方式 · 意见反馈 · 帮助中心</DD></DL></DIV></BODY></HTML>
<script type="text/javascript">



    /**
     * 房屋类型的下拉列表
     */
    selectType();
    function selectType(){
        $(function () {
            console.log('1111111');
            $.ajax({
                type:'post',
                url:'type!typeList.action',
                dataType:'json',
                success:function (data) {
                    var str1='';
                    $.each(data,function (index,obj) {
                        str1+='<option value='+obj.tid+'>'+obj.tname+'</option>';
                    });
                    $("select[name='type.tid']").append(str1);
                   /* console.log($("select[name='type.tid']").html());*/
                }
            });
        });
    }

    /**
     * 区县的下拉列表
     */
    selectDistrict();
    function  selectDistrict() {
        $(function () {
            console.log('2222222');
           $.ajax({
               type:'post',
               url:'district!districtList.action',
               dataType:'json',
               success:function (data) {
                   var str2='';
                   $.each(data,function (index,obj) {
                       str2+='<option value='+obj.did+'>'+obj.dname+'</option>';
                   });
                   $("select[name='district.did']").append(str2);
                  /* console.log($("select[name='district.did']").html());*/
               }
           });
        });
    }

    /**
     * 街道的下拉列表
     */
    selectStreet();
    function selectStreet(){
        console.log('333333');
        $(function () {
            $.ajax({
                type:'post',
                url:'street!streetList.action',
                data:{
                    did:$("select[name='district.did']").val()
                },
                dataType:'json',
                success:function (data) {
                    var str3='';
                    $.each(data,function (index,obj) {
                        str3+='<option value='+obj.sid+'>'+obj.sname+obj.district.did+obj.district.dname+'</option>';
                        /*str3+='<option value='+obj.sid+'>'+obj.sname+'</option>';*/
                    });
                    $("select[name='street.sid']").append(str3);
                    /* console.log($("select[name='street.sid']").html());*/
                }
            });
        });
    }

    $(function () {
        console.log('4444');
        $("select[name='district.did']").live('click',function () {
            console.log('555555');
            console.log($("select[name='district.did']").val());
            var did2val=$("select[name='district.did']").val();
            $("select[name='district.did'] option[value!="+did2val+"]").removeAttr('selected');
            $("select[name='district.did'] option[value="+did2val+"]").attr('selected','selected');
            console.log($("select[name='district.did'] option"));
            console.log($("select[name='district.did'] option[selected=selected]"));
            console.log($("select[name='district.did'] option[selected=selected]").val());
        });
    });






</script>


